package com.samshow.business.controller;

import com.samshow.baseVo.CaptionRequest;
import com.samshow.baseVo.DeleteCaptionRequest;
import com.samshow.baseservice.BXService;
import com.samshow.business.service.CaptionService;
import onbon.bx05.file.ControllerConfigBxFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
import java.util.List;

/**
 * Created by niwb on 2017/2/22.
 */
@Controller
public class BxCaptionContorller implements BXService {
    private Logger log = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private CaptionService captionService;
    @Autowired
    private HttpServletRequest request;

    @Override
    public boolean sendCaption(@RequestBody CaptionRequest captionRequest) {
        log.info("sendCaption BEGIN--" + captionRequest.getCaptions());
        captionService.sendCaption(captionRequest);
        log.info("sendCaption END");
        return true;
    }

    @Override
    public boolean setScreen(@RequestParam("netIds")String netIds, @RequestBody ControllerConfigBxFile bxFile) {
        log.info("setScreen BEGIN" + "netIds:" + netIds );
        Principal principal = request.getUserPrincipal();
        String id =  request.getSession().getId();
        log.info("setScreen END");
        return true;
    }

    @Override
    public boolean deletProgram(@RequestBody List<DeleteCaptionRequest> deleteCaptionRequest)
    {
        log.info("deletProgram BEGIN");
        log.info("deletProgram END");
        return true;

    }

    @Override
    public boolean addProgram(@PathVariable("userId") String userId, @RequestBody CaptionRequest captionRequest) {
        log.info("addProgram BEGIN");
        boolean result =  captionService.addProgram(userId,captionRequest.getProgramName(),captionRequest.getCaptions());
        log.info("addProgram END");
        return  result;
    }

    @Override
    public boolean sendCaptionSingle(String netId, String pId) {
        log.info("sendCaptionSingle BEGIN");
        captionService.sendCaptionSingle(netId,pId);
        log.info("sendCaptionSingle END");
        return false;
    }
}
